#include "managermodifyperson.h"
#include "ui_managermodifyperson.h"
#include <QDebug>
managerModifyPerson::managerModifyPerson(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::managerModifyPerson)
{
    ui->setupUi(this);
    this->setWindowTitle("修改学生/教师信息");
}

managerModifyPerson::~managerModifyPerson()
{
    delete ui;
}

void managerModifyPerson::getOldInfo(QStringList oldInfo,int whoAreYou)
{
    flag= whoAreYou;
    if(whoAreYou==2)
    {
        ui->edit_name->setText(oldInfo.at(0));
        ui->edit_id->setText(oldInfo.at(1));
        ui->edit_grade->setText(oldInfo.at(3));
        ui->edit_class->setText(oldInfo.at(4));
        ui->edit_college->setText(oldInfo.at(5));
        ui->edit_major->setText(oldInfo.at(6));
        ui->edit_password->setText(oldInfo.at(2));
    }
    else if(whoAreYou==1)
    {
        ui->edit_name->setText(oldInfo.at(0));
        ui->edit_id->setText(oldInfo.at(1));
        ui->edit_college->setText(oldInfo.at(3));
        ui->edit_level->setText(oldInfo.at(4));
        ui->edit_password->setText(oldInfo.at(2));
    }
}

QStringList managerModifyPerson::getNewInfo()
{
    return newInfo;
}

void managerModifyPerson::clearUi()
{
    ui->edit_name->clear();
    ui->edit_id->clear();
    ui->edit_grade->clear();
    ui->edit_class->clear();
    ui->edit_college->clear();
    ui->edit_major->clear();
    ui->edit_password->clear();
    ui->edit_level->clear();
    newInfo.clear();
    newInfo.append("0");
}

void managerModifyPerson::on_btn_confirm_2_clicked()
{
    newInfo.clear();
    if(flag==2)
    {
        newInfo.append(ui->edit_name->text());
        newInfo.append(ui->edit_id->text());
        newInfo.append(ui->edit_password->text());
        newInfo.append(ui->edit_grade->text());
        newInfo.append(ui->edit_class->text());
        newInfo.append(ui->edit_college->text());
        newInfo.append(ui->edit_major->text());
    }
    else if(flag==1)
    {
        newInfo.append(ui->edit_name->text());
        newInfo.append(ui->edit_id->text());
        newInfo.append(ui->edit_college->text());
        newInfo.append(ui->edit_level->text());
        newInfo.append(ui->edit_password->text());
    }
    this->close();
}

void managerModifyPerson::on_btn_exit_check_clicked()
{

    this->close();
}
